﻿using NPOI.SS.UserModel;
using System;
using System.IO;

namespace InsPipeInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                //删除当前目录下所有文本文件
                string filePath = System.AppDomain.CurrentDomain.BaseDirectory;
                DirectoryInfo directoryInfo = new DirectoryInfo(filePath);
                FileInfo[] fileInfos = directoryInfo.GetFiles();
                foreach (FileInfo info in fileInfos)
                {


                    string extension = info.Extension.ToLower();
                    if (extension == ".txt")
                    {
                        info.Delete();
                    }
                    if (extension == ".xlsx" && info.Name.Length > 20)
                    {
                        info.Delete();
                    }
                }
                try
                {
                    Console.Write("输入excel路径：");
                    string excelPath;
                    excelPath = Console.ReadLine();
                    if (!excelPath.Contains(".xlsx"))
                    {


                        excelPath = excelPath + ".xlsx";

                    }
                    if (File.Exists(excelPath))
                    {
                        Excel excel = new Excel();
                        ISheet sheet = excel.GetSheet(excelPath);
                        excel.ReadSheet(sheet);
                    }
                    else
                    {
                        Console.WriteLine("指定的文件不存在");
                    }

                }
                // catch ()
                // {

                // }
                catch (Exception e)
                {

                    Console.WriteLine(e.Message);

                }

                Console.ReadLine();
            }
        }
    }
}
